package com.nl.lib_project.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import com.nl.lib_project.R

/** 作者: wangfei 创建时间: 2021/9/17 包名: com.nl.lib_project.view 类名: UnderLineTextView */
class UnderLineTextView : androidx.appcompat.widget.AppCompatTextView {

  var paint =
      Paint().apply {
        color = context.resources.getColor(R.color.topic_not_selected)
        // 设置抗锯齿
        isAntiAlias = true
        isDither = true
        style = Paint.Style.FILL_AND_STROKE
      }

  constructor(context: Context) : super(context)

  constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

  constructor(
      context: Context,
      attrs: AttributeSet?,
      defStyleAttr: Int
  ) : super(context, attrs, defStyleAttr)

  override fun onDraw(canvas: Canvas?) {
    canvas?.drawLine(0f, this.height - 2f, this.width - 2f, this.height - 2f, paint)
    super.onDraw(canvas)
  }
}
